Skip to content

tests: add whitespace tests for vertical tab behavior#155028

Open
Brace1000 wants to merge 18 commits intorust-lang:mainfrom
Brace1000:whitespace-tests
Open

tests: add whitespace tests for vertical tab behavior#155028
Brace1000 wants to merge 18 commits intorust-lang:mainfrom
Brace1000:whitespace-tests

Conversation

@Brace1000
Copy link
Copy Markdown

@Brace1000 Brace1000 commented Apr 9, 2026

This PR adds two small tests to highlight how vertical tab (\x0B)
is handled differently across Rust's whitespace definitions.

The Rust lexer treats vertical tab as whitespace (Unicode
Pattern_White_Space), while split_ascii_whitespace follows the
WhatWG Infra Standard and does not include vertical tab.

These tests make that difference visible and easier to understand.

See: rust-lang/rust-project-goals#53

Add two small tests to highlight how vertical tab is handled differently.

- vertical_tab_lexer.rs checks that the lexer treats vertical tab as whitespace
- ascii_whitespace_excludes_vertical_tab.rs shows that split_ascii_whitespace does not split on it

This helps document the difference between the Rust parser (which accepts vertical tab)
and the standard library’s ASCII whitespace handling.

See: rust-lang/rust-project-goals#53
@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Apr 9, 2026
@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented Apr 9, 2026

r? @dingxiangfei2009

rustbot has assigned @dingxiangfei2009.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: compiler
  • compiler expanded to 69 candidates
  • Random selection from 11 candidates

@rustbot

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

Copy link
Copy Markdown
Author

@Brace1000 Brace1000 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fix tidy for whitespace tests spaces, trailing newline

View changes since this review

@rust-log-analyzer

This comment has been minimized.

fix tidy: add whitespace README entry
@rust-log-analyzer

This comment has been minimized.

arrange the tittle in alphabetical order
@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

Copy link
Copy Markdown
Contributor

@teor2345 teor2345 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, just needs a few tweaks

View changes since this review

let x = 5;
let y = 10;
let z = x + y;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since vertical tab doesn't show up in GitHub's PR review rendering, please put a comment above each line containing the whitespace.

You might want to add lines with each of the 11 permitted whitespace characters:
https://doc.rust-lang.org/reference/whitespace.html

And then some lines with the other 14 disallowed whitespace characters (the ones from this list marked White_Space, that aren't in the first list):
https://www.unicode.org/Public/UCD/latest/ucd/PropList.txt

@@ -0,0 +1,22 @@
// This test checks that split_ascii_whitespace does NOT split on
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if this test is relevant to the compiler?


Tests on `where` clauses. See [Where clauses | Reference](https://doc.rust-lang.org/reference/items/generics.html#where-clauses).

## `whitespace`
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will need an explanation of why the whitespace tests are needed. It's a good place to mention that is_ascii_whitespace and is_whitespace in the standard library don't match the Rust language's definition of whitespace.

// the standard library's is_ascii_whitespace does NOT include vertical
// tab, following the WhatWG Infra Standard instead.
//
// See: https://github.com/rust-lang/rust-project-goals/issues/53
Copy link
Copy Markdown
Contributor

@teor2345 teor2345 Apr 10, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

View changes since the review

Where did you get this link? It's not the Outreachy tracking issue.

@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented Apr 11, 2026

⚠️ Warning ⚠️

  • There are issue links (such as #123) in the commit messages of the following commits.
    Please move them to the PR description, to avoid spamming the issues with references to the commit, and so this bot can automatically canonicalize them to avoid issues with subtree.

  • The following commits have merge commits (commits with multiple parents) in your changes. We have a no merge policy so these commits will need to be removed for this pull request to be merged.

    You can start a rebase with the following commands:

    $ # rebase
    $ git pull --rebase https://github.com/rust-lang/rust.git main
    $ git push --force-with-lease
    

@rustbot rustbot added has-merge-commits PR has merge commits, merge with caution. S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Apr 11, 2026
@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer
Copy link
Copy Markdown
Collaborator

The job aarch64-gnu-llvm-21-1 failed! Check out the build log: (web) (plain enhanced) (plain)

Click to see the possible cause of the failure (guessed by this bot)
##[endgroup]
Executing "/scripts/stage_2_test_set1.sh"
+ /scripts/stage_2_test_set1.sh
+ '[' 1 == 1 ']'
+ echo 'PR_CI_JOB set; skipping tidy'
+ SKIP_TIDY='--skip tidy'
+ ../x.py --stage 2 test --skip tidy --skip compiler --skip src
PR_CI_JOB set; skipping tidy
##[group]Building bootstrap
    Finished `dev` profile [unoptimized] target(s) in 0.04s
##[endgroup]
---
error: ui test did not emit an error
note: by default, ui tests are expected not to compile.
hint: use check-pass, build-pass, or run-pass directive to change this behavior.
status: exit status: 0
command: env -u RUSTC_LOG_COLOR RUSTC_ICE="0" RUST_BACKTRACE="short" "/checkout/obj/build/aarch64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/tests/ui/whitespace/ascii_whitespace_excludes_vertical_tab.rs" "-Zthreads=1" "-Zsimulate-remapped-rust-src-base=/rustc/FAKE_PREFIX" "-Ztranslate-remapped-path-to-local-path=no" "-Z" "ignore-directory-in-diagnostics-source-blocks=/cargo" "-Z" "ignore-directory-in-diagnostics-source-blocks=/checkout/vendor" "--sysroot" "/checkout/obj/build/aarch64-unknown-linux-gnu/stage2" "--target=aarch64-unknown-linux-gnu" "--check-cfg" "cfg(test,FALSE)" "--error-format" "json" "--json" "future-incompat" "-Ccodegen-units=1" "-Zui-testing" "-Zdeduplicate-diagnostics=no" "-Zwrite-long-types-to-disk=no" "-Cstrip=debuginfo" "--emit" "metadata" "-C" "prefer-dynamic" "--out-dir" "/checkout/obj/build/aarch64-unknown-linux-gnu/test/ui/whitespace/ascii_whitespace_excludes_vertical_tab" "-A" "unused" "-W" "unused_attributes" "-A" "internal_features" "-A" "incomplete_features" "-A" "unused_parens" "-A" "unused_braces" "-Crpath" "-Cdebuginfo=0" "-Lnative=/checkout/obj/build/aarch64-unknown-linux-gnu/native/rust-test-helpers"
stdout: none
stderr: none

---- [ui] tests/ui/whitespace/ascii_whitespace_excludes_vertical_tab.rs stdout end ----
---- [ui] tests/ui/whitespace/vertical_tab_lexer.rs stdout ----
Saved the actual stderr to `/checkout/obj/build/aarch64-unknown-linux-gnu/test/ui/whitespace/vertical_tab_lexer/vertical_tab_lexer.stderr`
normalized stderr:
error[E0425]: cannot find value `let_ws2` in this scope
##[error]  --> $DIR/vertical_tab_lexer.rs:23:5
   |
LL |     let_ws2 = 2_i32;
   |     ^^^^^^^
   |
help: you might have meant to introduce a new binding
   |
LL -     let_ws2 = 2_i32;
LL +     let ws2 = 2_i32;
   |

error[E0425]: cannot find value `let_ws3` in this scope
##[error]  --> $DIR/vertical_tab_lexer.rs:26:5
   |
LL |     let_ws3 = 3_i32;
   |     ^^^^^^^
   |
help: you might have meant to introduce a new binding
   |
LL -     let_ws3 = 3_i32;
LL +     let ws3 = 3_i32;
   |

error[E0425]: cannot find value `let_ws5` in this scope
##[error]  --> $DIR/vertical_tab_lexer.rs:32:5
   |
LL |     let_ws5 = 5_i32;
   |     ^^^^^^^
   |
help: you might have meant to introduce a new binding
   |
LL -     let_ws5 = 5_i32;
LL +     let ws5 = 5_i32;
   |

error[E0425]: cannot find value `_ws2` in this scope
##[error]  --> $DIR/vertical_tab_lexer.rs:56:23
   |
LL |     let _sum = _ws1 + _ws2 + _ws3 + _ws4 + _ws5 + _ws6 + _ws7;
   |                       ^^^^
   |
help: a local variable with a similar name exists
   |
LL -     let _sum = _ws1 + _ws2 + _ws3 + _ws4 + _ws5 + _ws6 + _ws7;
LL +     let _sum = _ws1 + _ws1 + _ws3 + _ws4 + _ws5 + _ws6 + _ws7;
   |

error[E0425]: cannot find value `_ws3` in this scope
##[error]  --> $DIR/vertical_tab_lexer.rs:56:30
   |
LL |     let _sum = _ws1 + _ws2 + _ws3 + _ws4 + _ws5 + _ws6 + _ws7;
   |                              ^^^^
   |
help: a local variable with a similar name exists
   |
LL -     let _sum = _ws1 + _ws2 + _ws3 + _ws4 + _ws5 + _ws6 + _ws7;
LL +     let _sum = _ws1 + _ws2 + _ws1 + _ws4 + _ws5 + _ws6 + _ws7;
   |

error[E0425]: cannot find value `_ws5` in this scope
##[error]  --> $DIR/vertical_tab_lexer.rs:56:44
   |
LL |     let _sum = _ws1 + _ws2 + _ws3 + _ws4 + _ws5 + _ws6 + _ws7;
   |                                            ^^^^
   |
help: a local variable with a similar name exists
   |
LL -     let _sum = _ws1 + _ws2 + _ws3 + _ws4 + _ws5 + _ws6 + _ws7;
LL +     let _sum = _ws1 + _ws2 + _ws3 + _ws4 + _ws1 + _ws6 + _ws7;
   |

error: aborting due to 6 previous errors

For more information about this error, try `rustc --explain E0425`.
---
To only update this specific test, also pass `--test-args whitespace/vertical_tab_lexer.rs`

error: 1 errors occurred comparing output.
status: exit status: 1
command: env -u RUSTC_LOG_COLOR RUSTC_ICE="0" RUST_BACKTRACE="short" "/checkout/obj/build/aarch64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/tests/ui/whitespace/vertical_tab_lexer.rs" "-Zthreads=1" "-Zsimulate-remapped-rust-src-base=/rustc/FAKE_PREFIX" "-Ztranslate-remapped-path-to-local-path=no" "-Z" "ignore-directory-in-diagnostics-source-blocks=/cargo" "-Z" "ignore-directory-in-diagnostics-source-blocks=/checkout/vendor" "--sysroot" "/checkout/obj/build/aarch64-unknown-linux-gnu/stage2" "--target=aarch64-unknown-linux-gnu" "--check-cfg" "cfg(test,FALSE)" "--error-format" "json" "--json" "future-incompat" "-Ccodegen-units=1" "-Zui-testing" "-Zdeduplicate-diagnostics=no" "-Zwrite-long-types-to-disk=no" "-Cstrip=debuginfo" "--emit" "metadata" "-C" "prefer-dynamic" "--out-dir" "/checkout/obj/build/aarch64-unknown-linux-gnu/test/ui/whitespace/vertical_tab_lexer" "-A" "unused" "-W" "unused_attributes" "-A" "internal_features" "-A" "incomplete_features" "-A" "unused_parens" "-A" "unused_braces" "-Crpath" "-Cdebuginfo=0" "-Lnative=/checkout/obj/build/aarch64-unknown-linux-gnu/native/rust-test-helpers"
stdout: none
--- stderr -------------------------------
error[E0425]: cannot find value `let_ws2` in this scope
##[error]  --> /checkout/tests/ui/whitespace/vertical_tab_lexer.rs:23:5
   |
LL |     let_ws2 = 2_i32;
   |     ^^^^^^^
   |
help: you might have meant to introduce a new binding
   |
LL -     let_ws2 = 2_i32;
LL +     let ws2 = 2_i32;
   |

error[E0425]: cannot find value `let_ws3` in this scope
##[error]  --> /checkout/tests/ui/whitespace/vertical_tab_lexer.rs:26:5
   |
LL |     let_ws3 = 3_i32;
   |     ^^^^^^^
   |
help: you might have meant to introduce a new binding
   |
LL -     let_ws3 = 3_i32;
LL +     let ws3 = 3_i32;
   |

error[E0425]: cannot find value `let_ws5` in this scope
##[error]  --> /checkout/tests/ui/whitespace/vertical_tab_lexer.rs:32:5
   |
LL |     let_ws5 = 5_i32;
   |     ^^^^^^^
   |
help: you might have meant to introduce a new binding
   |
LL -     let_ws5 = 5_i32;
LL +     let ws5 = 5_i32;
   |

error[E0425]: cannot find value `_ws2` in this scope
##[error]  --> /checkout/tests/ui/whitespace/vertical_tab_lexer.rs:56:23
   |
LL |     let _sum = _ws1 + _ws2 + _ws3 + _ws4 + _ws5 + _ws6 + _ws7;
   |                       ^^^^
   |
help: a local variable with a similar name exists
   |
LL -     let _sum = _ws1 + _ws2 + _ws3 + _ws4 + _ws5 + _ws6 + _ws7;
LL +     let _sum = _ws1 + _ws1 + _ws3 + _ws4 + _ws5 + _ws6 + _ws7;
   |

error[E0425]: cannot find value `_ws3` in this scope
##[error]  --> /checkout/tests/ui/whitespace/vertical_tab_lexer.rs:56:30
   |
LL |     let _sum = _ws1 + _ws2 + _ws3 + _ws4 + _ws5 + _ws6 + _ws7;
   |                              ^^^^
   |
help: a local variable with a similar name exists
   |
LL -     let _sum = _ws1 + _ws2 + _ws3 + _ws4 + _ws5 + _ws6 + _ws7;
LL +     let _sum = _ws1 + _ws2 + _ws1 + _ws4 + _ws5 + _ws6 + _ws7;
   |

error[E0425]: cannot find value `_ws5` in this scope
##[error]  --> /checkout/tests/ui/whitespace/vertical_tab_lexer.rs:56:44
   |
LL |     let _sum = _ws1 + _ws2 + _ws3 + _ws4 + _ws5 + _ws6 + _ws7;
   |                                            ^^^^
   |
help: a local variable with a similar name exists
   |
LL -     let _sum = _ws1 + _ws2 + _ws3 + _ws4 + _ws5 + _ws6 + _ws7;
LL +     let _sum = _ws1 + _ws2 + _ws3 + _ws4 + _ws1 + _ws6 + _ws7;
   |

error: aborting due to 6 previous errors

For more information about this error, try `rustc --explain E0425`.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

has-merge-commits PR has merge commits, merge with caution. S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants